package com.duothread;

public class Demo1 {
    public static void main(String[] args) {
        SelfThread st1 = new SelfThread();
        SelfThread st2 = new SelfThread();
        // 给线程起名字
        st1.setName("线程1");
        st2.setName("线程2");
        st1.start();
        st2.start();

        for (int i = 1; i <= 10; i++) {
            System.out.println(i);
        }
    }
}

// 定义一个类继承Thread类，这个类就是线程类
class SelfThread extends Thread {
    // 重写run方法
    @Override
    public void run() {
        for (int i = 1; i <= 10; i++) {
            System.out.println(Thread.currentThread().getName() + "---" + i);
        }
    }
}